package com.gitee.wsl.platform.thread

import com.gitee.wsl.concurrent.executor.Executor
import com.gitee.wsl.concurrent.executor.sample.ImmediateExecutor
import kotlin.native.concurrent.ObsoleteWorkersApi
import kotlin.native.concurrent.Worker

@OptIn(ObsoleteWorkersApi::class)
object WorkRunners {

    fun immediate(): Executor {
        return ImmediateExecutor()
    }

    fun nativeWorker(
        name: String? = null,
        errorReporting: Boolean = true
    ): Executor {
        return NativeExecutor(Worker.start(errorReporting, name))
    }

    fun nativeWorker(worker: Worker): Executor {
        return NativeExecutor(worker)
    }
}
